package com.tongyi.lizhishop.views;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.blankj.utilcode.util.SizeUtils;
import com.tongyi.lizhishop.R;

import java.util.ArrayList;

/**
 * Created by meijun on 18-1-8.
 */

public class StarViewSmall extends LinearLayout {
    public StarViewSmall(Context context) {
        super(context);
        initView();
    }

    ArrayList<ImageView> views = new ArrayList<ImageView>();

    private void initView() {
        for (int i = 0; i < 5; i++) {
            ImageView imageView = new ImageView(getContext());
            // imageView.setImageResource(R.mipmap.small_start_check);
            views.add(imageView);
            LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            params.leftMargin = SizeUtils.dp2px(8);
            addView(imageView, params);
        }


    }

    public void setStarLight(int lightCount) {
        for (int i = 0; i < views.size(); i++) {
            ImageView imageView = views.get(i);
            if (i < lightCount) {
                imageView.setImageResource(R.mipmap.small_start_check);
            } else {
                imageView.setImageResource(R.mipmap.small_start_normal);

            }

        }
    }

    public StarViewSmall(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public StarViewSmall(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }
}
